home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / disk-man / mtools-3.000 / mtools-3 / mtools-3.0 / vfat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-03  |  2.4 KB  |  104 lines

  1. #ifndef MTOOLS_VFAT_H
  2. #define MTOOLS_VFAT_H
  3.  
  4. #include "msdos.h"
  5. #include "stream.h"
  6.  
  7. /*
  8.  * VFAT-related common header file
  9.  */
  10.  
  11. #define VFAT_SUPPORT
  12.  
  13. struct unicode_char {
  14.     char lchar;
  15.     char uchar;
  16. };
  17.  
  18.  
  19. /* #define MAX_VFAT_SUBENTRIES 32 */ /* Theoretical max # of VSEs */
  20. #define MAX_VFAT_SUBENTRIES 20        /* Max useful # of VSEs */
  21. #define VSE_NAMELEN 13
  22.  
  23. #define VSE1SIZE 5
  24. #define VSE2SIZE 6
  25. #define VSE3SIZE 2
  26.  
  27. struct vfat_subentry {
  28. #if 0
  29.     unsigned char ix;        /* 0x40 = last; & 0x1f = VSE ID */
  30. #endif
  31.     unsigned char id;        /* 0x40 = last; & 0x1f = VSE ID */
  32.     struct unicode_char text1[VSE1SIZE];
  33.     unsigned char attribute;    /* 0x0f for VFAT */
  34.     unsigned char hash1;        /* Always 0? */
  35.     unsigned char sum;        /* Checksum of short name */
  36.     struct unicode_char text2[VSE2SIZE];
  37.     unsigned char sector_l;        /* 0 for VFAT */
  38.     unsigned char sector_u;        /* 0 for VFAT */
  39.     struct unicode_char text3[VSE3SIZE];
  40. };
  41.  
  42. /* Enough size for a worst case number of full VSEs plus a null */
  43. #define VBUFSIZE ((MAX_VFAT_SUBENTRIES*VSE_NAMELEN) + 1)
  44.  
  45. /* Max legal length of a VFAT long name */
  46. #define MAX_VNAMELEN (255)
  47.  
  48. #define VSE_PRESENT 0x01
  49. #define VSE_LAST 0x40
  50. #define VSE_MASK 0x1f
  51.  
  52. struct vfat_state {
  53.     char name[VBUFSIZE];
  54.     int status; /* is now a bit map of 32 bits */
  55.     int subentries;
  56.     unsigned char sum; /* no need to remember the sum for each entry,
  57.                 * it is the same anyways */
  58. };
  59.  
  60.  
  61. struct scan_state {
  62.     int match_free;
  63.     int shortmatch;
  64.     int longmatch;
  65.     int free_start;
  66.     int free_size;
  67.     int slot;
  68.     int got_slots;
  69.     int size_needed;
  70.     int max_entry;
  71. };
  72.  
  73.  
  74. void clear_vfat(struct vfat_state  *);
  75. int check_vfat(struct vfat_state *v, struct directory *dir);
  76. int unicode_read(struct unicode_char *, char *, int num);
  77. int unicode_write(char *, struct unicode_char *, int num, int *end);
  78. unsigned char sum_shortname(char *);
  79. int write_vfat(Stream_t *, char *, char *, int);
  80. void clear_vses(Stream_t *, int, int);
  81. void autorename_short(char *, int);
  82. void autorename_long(char *, int);
  83.  
  84. int vfat_lookup(Stream_t *Dir, Stream_t *Fs,
  85.         struct directory *dir, int *entry,
  86.         int *beginpos,
  87.         char *filename,
  88.         int flags, char *outname,
  89.         char *shortname, char *longname,
  90.         Stream_t **File);
  91.  
  92. struct directory *dir_read(Stream_t *Stream,
  93.                struct directory *dir, 
  94.                int num, 
  95.                struct vfat_state *v);
  96.  
  97. #define DO_OPEN 1
  98. #define ACCEPT_PLAIN 0x20
  99. #define ACCEPT_DIR 0x10
  100. #define ACCEPT_LABEL 0x08
  101. #define SINGLE 2
  102. #define MATCH_ANY 0x40
  103. #endif
  104.